In object-oriented computer systems, system resources can be characterized in the form of an object. In some of these systems, the objects can be stored in arrays or tables and accessed through the use of keys. A key is a consistent value that identifies an object with respect to other objects and provides direct access to the object. Typically, hashcodes are utilized as keys.
Various approaches have been used to associate a hashcode with an object. In systems where the memory locations for objects are static, the memory location of the object is used as the hashcode. However, the use of the memory location as a hashcode cannot be applied to systems which relocate objects during a garbage collection process. Since the memory location of an object changes during the lifetime of an object, a hashcode that is dependent on a memory location could not provide a consistent value.
Another approach is to generate and store a hashcode with each object's data space. This approach is undesirable since it requires extra space in the object's data space which may never be utilized. While there may be a large number of objects which are hashable, most of them are not referenced by their hashcodes. As a result, this approach has the distinct disadvantage of requiring a large amount of memory.
It is an object of the present invention to provide a system and method for providing a hashcode for an object on an as-needed basis so as to avoid the allocation of memory space for hashcodes that are not referenced.
It is another object of the present invention to provide a system and method as described above that is computationally efficient and that imposes essentially no computational overhead for frequently hashed objects, and that uses storage resources that are proportional to the number of hashed objects.
It is another object of the present invention to provide a system and method as described above which provides a hashcode that identifies an object with respect to all the other objects, that is consistent for the duration of the object, and that is not based on the memory location of the object's data space.
It is another object of the present invention to provide a system and method as described above which provides a hashcode for an object in a concurrent processing environment.